<div class="container" ng-controller="SeedModules.Setup/modules/controllers/form">
    <div class="well well-lg">
        <h1>安装系统</h1>
        <hr>
        <p>就是需要先安装一下</p>
    </div>
    <form ajax-form="setupForm" name="form" role="form">
        <h6>
            <i class="glyphicon glyphicon-chevron-right"></i> 基本信息
            <hr>
        </h6>
        <div class="row">
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.ProjectName.$invalid }">
                <div>
                    <label>功能：</label>
                    <span class="text-danger pull-right" ng-show="form.ProjectName.$invalid">*必须选择功能</span>
                </div>
                <div class="input-group">
                    <input class="form-control" name="ProjectName" placeholder="选择功能模板" ng-model="projectFile.fileName" ng-readonly="true" required>
                    <div class="input-group-btn">
                        <button class="btn btn-danger" ng-click="projectFile.clear()" ng-show="projectFile.fileName&&projectFile.fileName!==''">
                            <i class="glyphicon glyphicon-remove"></i>
                        </button>
                        <button class="btn btn-default" ng-click="me.selectProject()">
                            <i class="fas fa-folder-open"></i>
                        </button>
                    </div>
                </div>
                <input file-input="projectFile" name="projectFile" style="visibility: collapse">
            </fieldset>
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.Name.$invalid }">
                <div>
                    <label>名称：</label>
                    <span class="text-danger pull-right" ng-show="form.Name.$invalid">*名称是必填的</span>
                </div>
                <div>
                    <input class="form-control" placeholder="输入名称" name="Name" ng-model="data.Name" ng-disabled="data.TenantCreated" required
                    />
                </div>
            </fieldset>
        </div>
        <h6 ng-if="!data.TenantCreated">
            <i class="glyphicon glyphicon-chevron-right"></i> 数据库信息
            <hr>
        </h6>
        <div class="row" ng-if="!data.TenantCreated">
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.DatabaseProvider.$invalid }">
                <div>
                    <label>数据库类型：</label>
                    <span class="text-danger pull-right" ng-show="form.DatabaseProvider.$invalid">*必须选择数据库类型</span>
                </div>
                <div>
                    <select class="form-control" name="DatabaseProvider" ng-model="data.DatabaseProvider" ng-init="data.DatabaseProvider='SqlConnection'"
                        required>
                        <option ng-repeat="item in databaseProviders" value="{{item.Provider}}">{{item.Name}}</option>
                    </select>
                </div>
            </fieldset>
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.TablePrefix.$invalid }">
                <div>
                    <label>表前缀：</label>
                    <span class="text-danger pull-right" ng-show="form.TablePrefix.$invalid">*表前缀是必填的</span>
                </div>
                <div>
                    <input class="form-control" placeholder="输入表前缀" name="TablePrefix" ng-model="data.TablePrefix" required />
                </div>
            </fieldset>

            <div ng-show="data.DatabaseProvider==='SqlConnection'" ng-init="me.initMsSql()">
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mssql_Server.$invalid }">
                    <div>
                        <label>服务地址：</label>
                        <span class="text-danger pull-right" ng-show="form.mssql_Server.$invalid">*服务地址是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mssql_Server" placeholder="输入服务地址" ng-model="mssql.Server" ng-required="data.DatabaseProvider==='SqlConnection'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mssql_Database.$invalid }">
                    <div>
                        <label>数据库名称：</label>
                        <span class="text-danger pull-right" ng-show="form.mssql_Database.$invalid">*数据库名称是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mssql_Database" placeholder="输入数据库名称" ng-model="mssql.Database" ng-required="data.DatabaseProvider==='SqlConnection'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mssql_Username.$invalid }">
                    <div>
                        <label>数据库账号：</label>
                        <span class="text-danger pull-right" ng-show="form.mssql_Username.$invalid">*数据库账号是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mssql_Username" placeholder="输入账号" ng-model="mssql.Username" ng-required="data.DatabaseProvider==='SqlConnection'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mssql_Password.$invalid }">
                    <div>
                        <label>数据库密码：</label>
                        <span class="text-danger pull-right" ng-show="form.mssql_Password.$invalid">*数据库密码是必填的</span>
                    </div>
                    <div>
                        <input type="password" class="form-control" name="mssql_Password" placeholder="输入密码" ng-model="mssql.Password" ng-required="data.DatabaseProvider==='SqlConnection'"
                        />
                    </div>
                </fieldset>
            </div>

            <div ng-show="data.DatabaseProvider==='MySql'" ng-init="me.initMySql()">
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mysql_Server.$invalid }">
                    <div>
                        <label>服务地址：</label>
                        <span class="text-danger pull-right" ng-show="form.mysql_Server.$invalid">*服务地址是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mysql_Server" placeholder="输入服务地址" ng-model="mysql.Server" ng-required="data.DatabaseProvider==='MySql'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mysql_Database.$invalid }">
                    <div>
                        <label>数据库名称：</label>
                        <span class="text-danger pull-right" ng-show="form.mysql_Database.$invalid">*数据库名称是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mysql_Database" placeholder="输入数据库名称" ng-model="mysql.Database" ng-required="data.DatabaseProvider==='MySql'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mysql_Username.$invalid }">
                    <div>
                        <label>数据库账号：</label>
                        <span class="text-danger pull-right" ng-show="form.mysql_Username.$invalid">*数据库账号是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="mysql_Username" placeholder="输入账号" ng-model="mysql.Username" ng-required="data.DatabaseProvider==='MySql'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.mysql_Password.$invalid }">
                    <div>
                        <label>数据库密码：</label>
                        <span class="text-danger pull-right" ng-show="form.mysql_Password.$invalid">*数据库密码是必填的</span>
                    </div>
                    <div>
                        <input type="password" class="form-control" name="mysql_Password" placeholder="输入密码" ng-model="mysql.Password" ng-required="data.DatabaseProvider==='MySql'"
                        />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6">
                    <div>
                        <label>端口号：</label>
                    </div>
                    <div>
                        <input class="form-control" name="mysql_Port" placeholder="输入端口号" ng-model="mysql.Port" />
                    </div>
                </fieldset>
                <fieldset class="form-group col-md-6">
                    <div>
                        <label>SSL：</label>
                    </div>
                    <div>
                        <!-- <input class="form-control" name="mysql_Ssl" placeholder="输入端口号" ng-model="mysql.Ssl" /> -->
                        <div class="btn-group">
                            <button class="btn btn-default" ng-click="mysql.Ssl=true" ng-class="{'active': mysql.Ssl}">启用</button>
                            <button class="btn btn-default" ng-click="mysql.Ssl=false" ng-class="{'active': !mysql.Ssl}">禁用</button>
                        </div>
                    </div>
                </fieldset>
            </div>

            <!-- <div ng-show="data.DatabaseProvider==='Sqlite'">
                <fieldset class="form-group col-md-12" ng-class="{ 'has-error': form.sqlite_Connection.$invalid }">
                    <div>
                        <label>连接字符串：</label>
                        <span class="text-danger pull-right" ng-show="form.sqlite_Connection.$invalid">*连接字符串是必填的</span>
                    </div>
                    <div>
                        <input class="form-control" name="sqlite_Connection" placeholder="输入连接字符串" ng-model="sqlite.Connection" ng-required="data.DatabaseProvider==='Sqlite'"
                        />
                    </div>
                </fieldset>
            </div> -->

        </div>
        <h6>
            <i class="glyphicon glyphicon-chevron-right"></i> 用户信息
            <hr>
        </h6>
        <div class="row">
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.UserName.$invalid }">
                <div>
                    <label>用户名：</label>
                    <span class="text-danger pull-right" ng-show="form.UserName.$invalid">*必须输入用户名</span>
                </div>
                <div>
                    <input class="form-control" placeholder="输入用户名" name="UserName" ng-model="data.UserName" required />
                </div>
            </fieldset>
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.Email.$invalid }">
                <div>
                    <label>邮箱：</label>
                    <span class="text-danger pull-right" ng-show="form.Email.$invalid">*必须输入用户名</span>
                </div>
                <div>
                    <input class="form-control" placeholder="输入邮箱" type="email" name="Email" ng-model="data.Email" required />
                </div>
            </fieldset>
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.Password.$invalid }">
                <div>
                    <label>密码：</label>
                    <span class="text-danger pull-right" ng-show="form.Password.$invalid">*必须输入密码</span>
                </div>
                <div>
                    <input type="password" class="form-control" placeholder="输入密码" name="Password" ng-model="data.Password" required />
                </div>
            </fieldset>
            <fieldset class="form-group col-md-6" ng-class="{ 'has-error': form.PasswordConfirmation.$invalid }">
                <div>
                    <label>确认密码：</label>
                    <span class="text-danger pull-right" ng-show="form.PasswordConfirmation.$invalid">*确认密码有误</span>
                </div>
                <div>
                    <input type="password" class="form-control" placeholder="输入密码" name="PasswordConfirmation" ng-model="data.PasswordConfirmation"
                        equals="data.Password" required />
                </div>
            </fieldset>
        </div>
        <div class="text-right">
            <button type="reset" class="btn btn-default">重置</button>
            <button type="button" class="btn btn-primary" ng-click="me.install()" ng-disabled="form.$invalid">开始安装</button>
        </div>
    </form>
</div>